from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

#添加部门弹框
class AddDepartmentDialog():

    add_department_dialog = (By.CSS_SELECTOR, '#__dialog__MNDialog__')
    ele_department_name = (By.CSS_SELECTOR, "div.qui_dialog_body.ww_dialog_body > div > form > div:nth-child(1) > input")
    ele_sumbit = (By.CSS_SELECTOR, "div.qui_dialog_foot.ww_dialog_foot > a.qui_btn.ww_btn.ww_btn_Blue")

    '''
    #添加部门
    def add_department(self, department):
        # 解决方案：https://www.cnblogs.com/91parson/p/11857664.html
        # 重复引用：https://blog.csdn.net/whatday/article/details/109333877
        # from page.contact_page import ContactPage
        #显性等待,等待弹框加载
        def wait(x):
            return find_element(self.driver, self.add_department_dialog)
        WebDriverWait(self.driver, 10).until(wait)

        find_element(self.driver, self.ele_department_name).send_keys(department)
        find_element(self.driver, self.ele_sumbit).click()

        return ContactPage(self.driver)
    '''